# Maintainer: Felix Yan <felixonmars@archlinux.org>

_hkgname=hxt-unicode
pkgname=haskell-hxt-unicode 
pkgver=9.0.2.4
pkgrel=25
pkgdesc="Unicode en-/decoding functions for utf8, iso-latin-* and other encodings"
url="https://www.fh-wedel.de/~si/HXmlToolbox/index.html"
license=('MIT')
arch=('loong64' 'x86_64')
depends=('ghc-libs' 'haskell-hxt-charproperties')
makedepends=('ghc')
source=("https://hackage.haskell.org/packages/archive/${_hkgname}/${pkgver}/${_hkgname}-${pkgver}.tar.gz")
sha512sums=('4daab9c754e05e15bb0f32bce4ccc0c581c6d8dd4ca4d4868ca7b756a6e40cc9ae8890fc3c925b63bb419db0354229ca6e61fa96bec048f0c61b3ebb43d212bb')

build() {
    cd $_hkgname-$pkgver
    
    runhaskell Setup configure -O --enable-shared --enable-executable-dynamic --disable-library-vanilla \
        --prefix=/usr --docdir=/usr/share/doc/$pkgname \
        --dynlibdir=/usr/lib --libsubdir=\$compiler/site-local/\$pkgid --ghc-option=-fllvm
    runhaskell Setup build $MAKEFLAGS
    runhaskell Setup register --gen-script
    runhaskell Setup unregister --gen-script
    sed -i -r -e "s|ghc-pkg.*update[^ ]* |&'--force' |" register.sh
    sed -i -r -e "s|ghc-pkg.*unregister[^ ]* |&'--force' |" unregister.sh
}

package() {
    cd $_hkgname-$pkgver
    
    install -D -m744 register.sh "$pkgdir"/usr/share/haskell/register/$pkgname.sh
    install -D -m744 unregister.sh "$pkgdir"/usr/share/haskell/unregister/$pkgname.sh
    runhaskell Setup copy --destdir="$pkgdir"
    install -D -m644 LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
    rm -f "$pkgdir"/usr/share/doc/$pkgname/LICENSE
}
